<template>
	<view class="container">
		<view class="list">
			<view class="item" v-for="(item,i) in list" :key="i">
				<view class="left">
					<image :src="item.image ? $img_base_url(item.image) : $img_path('/mine/wxq.jpg')" mode="aspectFill"></image>
					<text class="one-row">{{item.name}}</text>
				</view>
				<image @click="toEdit(2,item)" :src="$img_path('/pagesRegion/14.png')" mode="widthFix"></image>
			</view>
		</view>
		
		<view class="bottom-btn">
			<view class="b-box">
				<button @click="toEdit(1)">添加企业微信群</button>
			</view>
		</view>
	</view>
</template>

<script>
	import { getQunList } from '@/utils/api/serviceApi.js'
	export default {
		data() {
			return {
				page:1,
				list:[],
				total:0,
				last_page:0,
			};
		},
		onShow() {
			this.page = 1
			this.getQunList()
		},
		methods:{
			getQunList(){
				getQunList({
					page:this.page
				}).then(res=>{
					if(this.page==1){
						this.list = res.data
					}else{
						this.list = [...this.list,...res.data]
					}
				})
			},
			
			toEdit(type,data){
				let url = ''
				if(type==2){
					url = '/pagesRegion/WeChatGroup/add?form='+JSON.stringify(data)
				}else{
					url = '/pagesRegion/WeChatGroup/add'
				}
				uni.navigateTo({
					url
				})
			}
		},
		onReachBottom() {
			this.page++
			this.getQunList()
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
.container{
	.list{
		padding: 0 22rpx;
		box-sizing: border-box;
		.item{
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(180,180,180,0.16);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			border: 2rpx solid #FFA2A2;
			padding: 20rpx 26rpx 20rpx 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 20rpx;
			.left{
				width: calc(100% - 60rpx);
				display: flex;
				align-items: center;
				image{
					width: 120rpx;
					height: 120rpx;
					border-radius: 20rpx;
				}
				text{
					display: block;
					width: calc(100% - 140rpx);
					font-weight: bold;
					font-size: 36rpx;
					color: #333333;
					line-height: 50rpx;
					padding-left: 20rpx;
					box-sizing: border-box;
				}
			}
			&>image{
				width: 48rpx;
				height: 48rpx;
			}
		}
	}
}

.bottom-btn{
	width: 100%;
	height: calc(constant(safe-area-inset-bottom) + 140rpx);
	height: calc(env(safe-area-inset-bottom) + 140rpx);
	.b-box{
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		padding: 20rpx 22rpx 0;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
		box-sizing: border-box;
		button{
			width: 100%;
			height: 96rpx;
			background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
			border-radius: 80rpx;
			font-weight: bold;
			font-size: 36rpx;
			color: #FFFFFF;
			line-height: 96rpx;
		}
	}
}
</style>
